﻿@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
<link href="~/lib/layui/css/layui.css" rel="stylesheet" />
<script src="~/lib/layui/layui.js"></script>
<script src="~/lib/jquery/dist/jquery.js"></script>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>IMES</title>
</head>
<body>
    <div class="layui-panel">
        <div style="padding: 32px;">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label" style="font-weight: bold;float: left;">审核</label>
                    <div style="margin-left: 600px;">
                        <input type="text" placeholder="订单编号" id="orderId" style="line-height:25px;">
                        <button class="layui-btn layui-bg-blue" onclick="yes(1)" style="height:29px;line-height:14px">审批通过</button>
                        <button class="layui-btn" onclick="yes(2)" style="height:29px;line-height:14px">审批不通过</button>
                    </div>
                </div>
                <table class="layui-hide" id="ID-table-demo-templet"></table>
            </div>
        </div>

    </div>
    <script>
        layui.use(['table'], function () {
            var form = layui.form
            var laypage = layui.laypage;
            var $ = layui.$;
            var layer = layui.layer;
            var util = layui.util;
            var table = layui.table;
            $(function () {
                getList();
            })

            //列表显示
            function getList() {
				var data = {
					username: localStorage.getItem("username"),
				}
                $.ajax({
					url: '@ViewBag.Darius' + "/api/Approval/ShowApproval",
					data: JSON.stringify(data),
                    dataType: "post",
                    success: function (res) {
                        console.log(res)
						table.render({
							elem: '#ID-table-demo-templet', // 表格元素的ID
							data: res.data, // 数据列表							
							toolbar: '#toolbarDemo',
							defaultToolbar: [
								'filter',
								'exports',
								'print',
								{
									// 右上角工具图标
									title: '提示',
									layEvent: 'LAYTABLE_TIPS',
									icon: 'layui-icon-tips',
									onClick: function (obj) {
										// 2.9.12+
										layer.alert('自定义工具栏图标按钮');
									},
								},
							],
							height: 'full-35', // 最大高度减去其他容器已占有的高度差
							cols: [
								[
                                    { type: 'checkbox', fixed: 'left' },
                                    { field: 'createName', width: 80, title: '订单编号', },
                                    { field: 'updateName', width: 80, title: '事件', },
                                    { field: 'updateDate', width: 150, title: '审核人', },
								]
							]
						});
                     
                    }
                });
            }

			//修改状态
			function yes(id) {

				console.log(typess)
				// 获取选中行的数据
				var checkStatus = table.checkStatus('ID-table-demo-templet'); // 'test' 是你表格的 lay-filter 值
				var checkedData = checkStatus.data; // 获取选中行的数据数组

				// 从选中行数据中提取 workSheetId
				var workSheetIdss = checkedData.map(function (item) {
					return item.workSheetId;
				});
				console.log(workSheetIdss)
				var data = {
					status: id
				}
				console.log(JSON.stringify(data))
				$.ajax({
					url: '@ViewBag.Darius' + "/api/Approval/UpdateApproval",
					data: JSON.stringify(data),
					dataType: "json",
					type: "Put",
					contentType: "application/json",
					success: function (res) {
						console.log(res)
						if (res.code > 0) {
							layer.msg(res.messege);
						}
						else {
							//错误提示
							layer.msg(res.messege);
						}
					}
				});


			}
        })



    </script>

</body>
</html>

